package General;
/**
 * 
 * Resource encapsulates all the types of resource cubes into one class. 
 * Each quantity of resource cube is represented as an integer in the order of:
 * food, wood, favor, gold, victory
 */
public final class Resource {
	//Resource will be used to encapsulate ALL the types or resource cubes.
	//Will work inside player wallet, bank wallet, and purchase prices
		//might want to convert to a int[5]
	private final int food;
	private final int wood;
	private final int favor;
	private final int gold;
	//private final int victory;
	/**
	 * Zero value constructor
	 */
	public Resource() {
		food = 0;
		wood = 0;
		favor =0;
		gold = 0;
		//victory = 0;
	}
	
	/** 
	 * Initialize wallet by declaring the value of each type
	 * @param Subtype food, wood, favor, gold, victory
	 */
	public Resource(int food, int wood, int favor, int gold){
		this.food = food;
		this.wood = wood;
		this.favor = favor;
		this.gold = gold;
//		this.victory =victory;
	}
	public Resource(int food, int wood, int favor, int gold, int dontHateMePlz){
		this(food,wood,favor,gold);
	}

	public Resource(Resources res, int i){
		food = (res == Resources.FOOD)?i:0;
		wood = (res == Resources.WOOD)?i:0;
		favor =(res == Resources.FAVOR)?i:0;
		gold = (res == Resources.GOLD)?i:0;
//		victory = (res == Resources.VICTORY)?i:0;
	}
	/**
	 * @param in the resource to be added to this resource
	 * @return Resource container with the combined value of this Resource + in
	 */
	public Resource addResource(Resource in){
		return new Resource(this.food+in.getFood(), this.wood+in.getWood(), 
				this.favor+in.getFavor(), this.gold+in.getGold());
	}
	/**
	 * 
	 * @param in
	 * @return Resource with the specified funds subtracted from this resources funds
	 */
	public Resource subtractResource(Resource in){
		return new Resource(this.food-in.getFood(), this.wood-in.getWood(), 
				this.favor-in.getFavor(), this.gold-in.getGold());
	}
	/**
	 * quick and dirty if time permits, replace with comparable interface
	 * @param in
	 * @return
	 */
	public boolean creditCheck(Resource in){
		if(this.food<in.getFood())	return false;
		if(this.wood<in.getWood())	return false;
		if(this.favor<in.getFavor())return false;
		if(this.gold<in.getGold())	return false;
//		if(this.victory<in.getVictory())return false;
		return true;
	}
	public int getFood(){
		return food;
	}
	public int getWood(){
		return wood;
	}
	public int getFavor(){
		return favor;
	}
	public int getGold(){
		return gold;
	}
//	public int getVictory(){
//		return victory;
//	}
	public String toString(){
		return "Fd "+food+" Wd "+wood+" Fv "+favor+" Gd "+gold;
	}
}
